<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 微信用户标签
 */
class CreateWxUserTag extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //微信用户标签表
        Schema::create('wx_user_tags', function (Blueprint $table) {
            $table->increments('tag_id')->comment('标签ID');
            $table->string('appid', 64)->default('')->comment('微信应用ID');
            $table->unsignedInteger('parent_id')->comment('父级标签ID');
            $table->unsignedInteger('wx_tag_id')->comment('微信标签ID');
            $table->string('tag_name', 30)->default('')->comment('标签名称');
            $table->unsignedInteger('user_count')->comment('用户数');
            $table->unsignedSmallInteger('order_num')->default(0)->comment('排序数字，值越小越靠前');
            $table->softDeletes();
            $table->timestamps();
            $table->index(['appid','wx_tag_id'], 'idx_1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::dropIfExists('wx_user_tags');
    }
}
